/**
 * jims
 */
package com.jims.master.modules.base.user.service;


import com.jims.master.modules.base.user.dao.MasterBaseinfoDao;
import com.jims.master.modules.base.user.dao.MasterDoctorinfoDao;
import com.jims.master.modules.base.user.entity.MasterBaseinfo;
import com.jims.master.modules.base.user.entity.MasterDoctorinfo;
import com.jims.master.modules.sys.entity.User;

import com.jims.master.common.persistence.Page;
import com.jims.master.common.service.CrudService;
import com.jims.master.common.utils.DateUtils;

import com.jims.master.modules.sys.service.UserService;
import com.jims.master.modules.sys.utils.UserUtils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 医生信息Service
 * @author jicunteng
 * @version 2017-06-27
 */
@Service
@Transactional(readOnly = true)
public class MasterDoctorinfoService extends CrudService<MasterDoctorinfoDao, MasterDoctorinfo> {

	@Autowired
	private UserService userService;
	@Autowired
	private MasterBaseinfoDao masterBaseinfoDao;

	/**
	 * 医生总数
	 * @author 陈涛
	 * @return
	 */
	public int doctorCount(MasterDoctorinfo masterDoctorinfo){return dao.doctorCount(masterDoctorinfo);}



	/**
	 * 申请医生列表
	 * @return
	 */
	public List<MasterDoctorinfo> findApplyList(MasterDoctorinfo masterDoctorinfo){return dao.findApplyList(masterDoctorinfo);}

	/**
	 * 首页排序医生查询
	 * @param masterDoctorinfo
	 * @author 陈涛
	 * @return
	 */
	public List<MasterDoctorinfo> findListIndex(MasterDoctorinfo masterDoctorinfo){
		return dao.findListIndex(masterDoctorinfo);
	}

	/**
	 * 根據baseinfoId查詢醫生信息
	 */
	public MasterDoctorinfo getDoctorinfoByBaseinfoId(String persionId){
		return dao.getDoctorinfoByBaseinfoId(persionId);
	}

	/**
	 * 得到同科室医生
	 * @param masterDoctorinfo
	 * @author 陈涛
	 * @return
	 */
	public List<MasterDoctorinfo> findListByParts(MasterDoctorinfo masterDoctorinfo){return dao.findListByParts(masterDoctorinfo);}

	/**
	 * 根据医院得到医院的科室
	 * @param mechanism
	 * @author 陈涛
	 * @return
	 */
	public List<MasterDoctorinfo> getPartsByMechanism(String mechanism){
		return dao.getPartsByMechanism(mechanism);
	}

	/**
	 * 查询注册医生所在的医院
	 * @author 陈涛
	 * @return
	 */
	public List <String> getMechanism(){
		return dao.getMechanism();
	}

	/**
	 * 根据ID查询数据
	 * @param baseInfo
	 * @return
	 * @author jicunteng
	 */
	public MasterDoctorinfo getDocByBaseinfo(MasterBaseinfo baseInfo) {
		return dao.getDocByBaseinfo(baseInfo);
	}

	/**
	 * 上传医生证件
	 * @param file
	 * @param request
	 * @return
	 * @throws Exception
	 *//*
	@Transactional(readOnly = false)
	public String saveDoctorPic(MultipartFile file,HttpServletRequest request) throws Exception {

		User user= UserUtils.getUser();
		String home = request.getSession().getServletContext().getRealPath("");
		String pathImg="doctorImage";
		String datePath= DateUtils.formatDate(new Date(), "yyyy/MM/dd");
		String pathUrl= File.separator+pathImg+File.separator+datePath+File.separator+"checkDoctorImg";
		String str = UUIDUtil.getUUID();
		String headPath = str+ "." ;
		String fileName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1,file.getOriginalFilename().length());
		pathUrl=pathUrl+File.separator+headPath+fileName;
		File fileTemp = new File(home+pathUrl);
		if(!fileTemp.exists())
			fileTemp.mkdirs();

		file.transferTo(fileTemp);
		//文件名为当前时间
		return pathUrl;
	}
*/
	/**
	 * 审核医生
	 * @return
	 */
	@Transactional(readOnly = false)
	public int checkDoctorById(MasterDoctorinfo masterDoctorinfo){
		return dao.checkDoctorById(masterDoctorinfo);
	}

	public List<MasterDoctorinfo> getDocByArea(String hospital,String parts,String area){
		return dao.getDocByArea(hospital,parts,area);
	}

	public List<MasterDoctorinfo> getDocBys(String hospital,String parts,String area){
		return dao.getDocBys(hospital,parts,area);
	}

	public List<MasterDoctorinfo> getAllDoc(){
		return dao.getAllDoc();
	}

}